<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网站后台管理系统HTML模板--模板之家 www.cssmoban.com</title>
<link href="css/style1.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>

<script type="text/javascript">
$(document).ready(function(){
  $(".click").click(function(){
  $(".tip").fadeIn(200);
  });
  
  $(".tiptop a").click(function(){
  $(".tip").fadeOut(200);
});

  $(".sure").click(function(){
  $(".tip").fadeOut(100);
});

  $(".cancel").click(function(){
  $(".tip").fadeOut(100);
});

});
</script>


</head>


<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">数据表</a></li>
    <li><a href="#">基本内容</a></li>
    </ul>
    </div>

    <div class="rightinfo">

    <div class="tools">

    	<ul class="toolbar">
        <li class="click"><span><img src="images/t01.png" /></span>添加</li>
        <li class="click"><span><img src="images/t02.png" /></span>修改</li>
        <li onclick="delAll()"><span><img src="images/t03.png" /></span>删除所选中</li>
        <li><span><img src="images/t04.png" /></span>统计</li>
        </ul>


        <ul class="toolbar1">
        <li><span><img src="images/t05.png" /></span>设置</li>
        </ul>

    </div>

    <script type="text/javascript">
    function checkfk(){
        var allcheck=document.getElementById("checkAll");  //获取 全选check 的id
        var othercheck=document.getElementsByName("check"); //获取数组名称为fkcheck的 复选框
        for(var i in othercheck){
            if(allcheck.checked){
                othercheck[i].checked=true;
            }else{
                othercheck[i].checked=false;
            }
        }
    }  //循环遍历 复选框 ，当点击全选时，其它被选中，否则取消选中

    </script>

    <table class="tablelist">
    	<thead>
    	<tr>
        <th><input name="" id="checkAll" type="checkbox" value="" checked="checked" onclick="checkfk()"/></th>
        <th>编号<i class="sort"><img src="images/px.gif" /></i></th>
        <th>标题</th>
        <th>用户</th>
        <th>发布时间</th>
        <th>是否审核</th>
        <th>审核状态</th>
        <th>审核</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${res.list}" var="jokeVo">

        <tr>
        <td><input name="check" type="checkbox" value="${jokeVo.jid}" /></td>
        <td>${jokeVo.jid}</td>
        <td>${jokeVo.jdesc}</td>
        <td>${jokeVo.jauthor}</td>
        <td>${jokeVo.jstatus}</td>
        <td>${jokeVo.jcreatetime}</td>
            <c:if test="${jokeVo.jstatus == 0}">
                <td>未审核</td>
            </c:if>
            <c:if test="${jokeVo.jstatus == 1}">
                <td>已批准</td>
            </c:if>
            <c:if test="${jokeVo.jstatus == -1}">
                <td>不通过</td>
            </c:if>
        <td><a href="javascript:void(0)" class="del" onclick="del(${jokeVo.jid},1)">删除</a></td>
        </tr>


    </c:forEach>
        </tbody>
        </table>
        <script type="text/javascript" >
            function del(jid) {
                $.ajax({
                    type: "POST",
                    url: "${pageContext.request.contextPath}/joke/admin/delUnPass",
                    data: {"jid":jid},
                    dataType:"json",
                    async : true,
                    success: function(value) {
                        console.log(value);
                        alert(value.msg);
                    },
                    error: function() {
                        alert("删除出错！");
                    }
                });
            }
        </script>

        <script type="text/javascript">
            function delAll() {
                obj = document.getElementsByName("check");
                checkval = [];
                for(k in obj){
                    if (!isNaN(k)) {
                        if (obj[k].checked)
                            checkval.push(obj[k].value);
                    }
                }
                var ids = JSON.stringify(checkval);
                console.log(checkval);
                $.ajax({
                    type: "POST",
                    url: "${pageContext.request.contextPath}/joke/admin/delUnPassAll",
                    data: ids,
                    dataType:"json",
                    async : true,
                    contentType: 'application/json;charset=utf-8',
                    success: function(value) {
                        console.log(value);
                        alert(value.msg);
                    },
                    error: function() {
                        alert(value.msg);
                    }
                });


            }
        </script>
        <!-- 提示分页信息行 -->
        <div class="pagin">
            <!-- 分页文字信息 ：拿到控制器处理请求时封装在pageInfo里面的分页信息-->
            <div class="message">
                当前${res.pageNum}页,共${res.pages }页,总${res.total }条记录
            </div>
            <!-- 分页码 -->
                    <ul class="pagination">
                        <!--
                                      1.pageContext.request.contextPath表示当前项目路径，采用的是绝对路径表达方式。一般为http:localhost:8080/项目名 。
                                      2.首页，末页的逻辑：pn=1访问第一次，pn=res.pages访问最后一页
                                    -->
                        <li>
                            <a href="${pageContext.request.contextPath}/joke/admin/selectUnPass?pageNum=1">首页</a>
                        </li>
                        <!-- 如果还有前页就访问当前页码-1的页面， -->
                        <c:if test="${res.hasPreviousPage}">
                            <li>
                                <a href="${pageContext.request.contextPath}/joke/admin/selectUnPass?pageNum=${res.pageNum-1}" aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </li>
                        </c:if>
                        <li>
                            <!--遍历所有导航页码，如果遍历的页码页当前页码相等就高亮显示，如果相等就普通显示  -->

                        <li class="active"><a href="#">${page_Nums}</a> <c:forEach items="${res.navigatepageNums }" var="page_Nums">
                                <c:if test="${page_Nums==res.pageNum }"></li>
                        </c:if>
                        <c:if test="${page_Nums!=res.pageNum }">
                            <li ><a href="${pageContext.request.contextPath}/joke/admin/selectUnPass?pageNum=${page_Nums}">${page_Nums}</a></li>
                        </c:if>
                        </c:forEach>
                        </li>
                        <!-- 如果还有后页就访问当前页码+1的页面， -->
                        <c:if test="${res.hasNextPage}">
                            <li>
                                <a href="${pageContext.request.contextPath}/joke/admin/selectUnPass?pageNum=${res.pageNum+1}" aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </li>
                        </c:if>
                        <li><a href="${pageContext.request.contextPath}/joke/admin/selectUnPass?pageNum=${res.pages}">末页</a></li>
                    </ul>
        </div>


    <div class="tip">
    	<div class="tiptop"><span>提示信息</span><a></a></div>

      <div class="tipinfo">
        <span><img src="images/ticon.png" /></span>
        <div class="tipright">
        <p>是否确认对信息的修改 ？</p>
        <cite>如果是请点击确定按钮 ，否则请点取消。</cite>
        </div>
        </div>

        <div class="tipbtn">
        <input name="" type="button"  class="sure" value="确定" />&nbsp;
        <input name="" type="button"  class="cancel" value="取消" />
        </div>

    </div>




    </div>

    <script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
	</script>
</body>
</html>
